Imports CapaDeDatos
Public Class nEnteC
    Private TblEnteC As dEnteC = New dEnteC()
    Private Localidad As CapaDeDatos.dLocalidad = New CapaDeDatos.dLocalidad
    Public Function Insertar(ByVal RazonSocial As String, ByVal Direccion As String, ByVal TelCel As String, ByVal Mail As String, ByVal CodigoLocalidad As String) As Boolean
        If (RazonSocial <> "" And Direccion <> "" And CodigoLocalidad <> "" And Not TblEnteC.Existe(RazonSocial, "")) Then
            Return TblEnteC.Insertar(RazonSocial, Direccion, TelCel, Mail, CodigoLocalidad)
        Else
            Return False
        End If
    End Function
    Public Function Modificar(ByVal CodigoEnte As String, ByVal RazonSocial As String, ByVal Direccion As String, ByVal TelCel As String, ByVal Mail As String, ByVal Estado As String, ByVal CodigoLocalidad As String) As Boolean
        Return TblEnteC.Modificar(CodigoEnte, RazonSocial, Direccion, TelCel, Mail, Estado, CodigoLocalidad)
    End Function
    Public Function Buscar(ByVal CodigoEnte As String, _
                            ByVal RazonSocial As String, _
                            ByVal Direccion As String, _
                            ByVal TelCel As String, _
                            ByVal Mail As String, _
                            ByVal CodigoLocalidad As String) As DataSet
        Dim DtsPrincipal As DataSet
        DtsPrincipal = TblEnteC.BuscarFiltrado(CodigoEnte, RazonSocial, Direccion, TelCel, Mail, CodigoLocalidad)

        DtsPrincipal.Tables(0).Columns.Add("Nombre")
        Dim I As Integer

        For I = 0 To DtsPrincipal.Tables(0).Rows.Count - 1
            Try
                DtsPrincipal.Tables(0).Rows(I)("Nombre") = Localidad.ListarNombres(DtsPrincipal.Tables(0).Rows(I)("CodigoLocalidad").ToString(), "").Tables(0).Rows(0)("Nombre").ToString()
            Catch ex As Exception
                DtsPrincipal.Tables(0).Rows(I)("Nombre") = "Nombre No Registrado"
            End Try
        Next


        'If CodigoLocalidad = "-1" Then
        '    CodigoLocalidad = ""
        'End If

        'Dim dtsPrincipal As DataSet
        'dtsPrincipal = TblEnteC.BuscarFiltrado(CodigoEnte, RazonSocial, Direccion, TelCel, Mail, CodigoLocalidad)
        'dtsPrincipal.Tables(0).Columns.Add("Codigolocalidad")
        'Dim i As Integer
        'For i = 0 To dtsPrincipal.Tables(0).Rows.Count - 1
        '    Try
        '        dtsPrincipal.Tables(0).Rows(i)("Codigolocalidad") = Localidad.Buscar(dtsPrincipal.Tables(0).Rows(i)("CodigoLocalidad").ToString()).Tables(0).Rows(0)("Nombre").ToString()
        '    Catch ex As Exception
        '        dtsPrincipal.Tables(0).Rows(i)("Codigolocalidad") = "Error, lo q vos quieras"
        '    End Try
        'Next
        Return DtsPrincipal

    End Function
    Public Function Eliminar(ByVal CodigoEnte As String) As Boolean
        If (CodigoEnte <> "") Then
            Return TblEnteC.Eliminar(CodigoEnte)
        Else
            Return False
        End If
    End Function
End Class
